Click here to get back home

What's the difference between /usr/(lib|share)/(perl|perl5)?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
What's the difference between /usr/(lib|share)/(perl|perl5)? Stefano Sabatini 03-03-2007
Posted by Stefano Sabatini on March 3, 2007, 10:41 am
Please log in for more thread options


Hi all.

Can someone tell the difference between:

/usr/lib/perl
/usr/lib/perl5
/usr/share/perl
/usr/share/perl5

and the corresponding dir with the /usr/local prefix (or tell a
relevant link)?

I know about @INC, that in my system (debian etch, perl 5.8.8) returns:

/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8
/usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
/usr/local/lib/site_perl

I noticed that CPAN seems to install modules in
/usr/local/lib/perl/5.8.8

but frankly I can't actually tell the difference between modules
installed in all these various directories (apart from the obvious fact
that /usr/local is used for installing modules not managed by the
package management system).

In particular where am I supposed to put modules used by scripts that
only have to run in my system, and where am I supposed to put
modules in a source perl package (/usr/local/share/perl,
/usr/local/lib/perl, /usr/local/share/perl5, /usr/local/lib/perl5 ?).

Many thanks in advance
Cheers
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

Posted by Peter J. Holzer on March 3, 2007, 1:03 pm
Please log in for more thread options


> Can someone tell the difference between:
>
> /usr/lib/perl
> /usr/lib/perl5
> /usr/share/perl
> /usr/share/perl5
>
> and the corresponding dir with the /usr/local prefix (or tell a
> relevant link)?
>
> I know about @INC, that in my system (debian etch, perl 5.8.8) returns:
>
> /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8
> /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
> /usr/local/lib/site_perl

So you are actually asking about the difference between:

/usr/lib/perl/5.8
/usr/lib/perl5
/usr/share/perl/5.8
/usr/share/perl5

? That's more a Debian/Linux question than a Perl question.

/usr/lib is meant for platform-specific code and (read-only) data. If a module
contains compiled code, it should go there. /usr/share is meant for
platform-independent code and (read-only) data: Pure perl modules should
go there.

Similarily, modules which need perl 5.8.x should go into .../perl/5.8
while modules which work with any perl 5 can go inot .../perl5.

> I noticed that CPAN seems to install modules in
> /usr/local/lib/perl/5.8.8

Yup. Locally installed stuff should go into /usr/local. Since cpan
doesn't install into different places according to debian policy,
everything is installed into the most specific place: .../lib/...
because the module might be platform dependent, and .../perl/5.8.8
because it might not work with any other version.

> In particular where am I supposed to put modules used by scripts that
> only have to run in my system, and where am I supposed to put
> modules in a source perl package (/usr/local/share/perl,
> /usr/local/lib/perl, /usr/local/share/perl5, /usr/local/lib/perl5 ?).

Use Module::Builder or ExtUtils::MakeMaker to install your modules. That
will "do the right thing" if perl was setup sanely by your linux
distribution (as is the case for Debian Etch).

        hp

--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ |        -- Nils Ketelsen in danr

Posted by Stefano Sabatini on March 3, 2007, 4:58 pm
Please log in for more thread options


Hi Peter.

>> Can someone tell the difference between:
>>
>> /usr/lib/perl
>> /usr/lib/perl5
>> /usr/share/perl
>> /usr/share/perl5
>>
>> and the corresponding dir with the /usr/local prefix (or tell a
>> relevant link)?
>>
> [CUT]
> So you are actually asking about the difference between:
>
> /usr/lib/perl/5.8
> /usr/lib/perl5
> /usr/share/perl/5.8
> /usr/share/perl5
>
> ? That's more a Debian/Linux question than a Perl question.
>
> /usr/lib is meant for platform-specific code and (read-only) data. If a module
> contains compiled code, it should go there. /usr/share is meant for
> platform-independent code and (read-only) data: Pure perl modules should
> go there.
>
> Similarily, modules which need perl 5.8.x should go into .../perl/5.8
> while modules which work with any perl 5 can go inot .../perl5.

OK, much clearer now, thanks!

Mmh... so perl5 should be used for modules that should work with
*every* version of perl 5.x.y, while the various
<prefix>/(share|lib)/perl/<version> dirs should contain modules
specific for a specific version... thus in order to avoid errors one
should always choose the version specific directory, that is what cpan
seems to automatically do.

Is it right?

> [CUT]
>> In particular where am I supposed to put modules used by scripts that
>> only have to run in my system, and where am I supposed to put
>> modules in a source perl package (/usr/local/share/perl,
>> /usr/local/lib/perl, /usr/local/share/perl5, /usr/local/lib/perl5 ?).
>
> Use Module::Builder or ExtUtils::MakeMaker to install your modules. That
> will "do the right thing" if perl was setup sanely by your linux
> distribution (as is the case for Debian Etch).
>

Yes, it's a wise advice, but I was trying to build a package with a
perl script and a specific perl module (not meant to be used
indipendently from the script), and I wanted to avoid to mix autoconf
and MakeMaker, so the simple solution seemed to detect the
installation dirs without to rely on not autoconf/make tools.

Cheers
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

Posted by Peter J. Holzer on March 4, 2007, 5:43 am
Please log in for more thread options


> Hi Peter.
>
>>>
>> So you are actually asking about the difference between:
>>
>> /usr/lib/perl/5.8
>> /usr/lib/perl5
>> /usr/share/perl/5.8
>> /usr/share/perl5
>>
>> ? That's more a Debian/Linux question than a Perl question.
>>
>> /usr/lib is meant for platform-specific code and (read-only) data. If a module
>> contains compiled code, it should go there. /usr/share is meant for
>> platform-independent code and (read-only) data: Pure perl modules should
>> go there.
>>
>> Similarily, modules which need perl 5.8.x should go into .../perl/5.8
>> while modules which work with any perl 5 can go inot .../perl5.
>
> OK, much clearer now, thanks!
>
> Mmh... so perl5 should be used for modules that should work with
> *every* version of perl 5.x.y, while the various
><prefix>/(share|lib)/perl/<version> dirs should contain modules
> specific for a specific version... thus in order to avoid errors one
> should always choose the version specific directory, that is what cpan
> seems to automatically do.
>
> Is it right?

Yep, except for the "should always". What you should do depends on what
you are trying to achieve. cpan installs a module on a single machine
for a specific version of perl - so it chooses the most specific
directory to avoid disturbing other perl versions which might be
installed on the same machine. If you are building a package which
should be installed on many machines, maybe with different linux
distributions and perl versions, you need to install into a directory
which is in @INC on all of these machines (for example, when I created
RPMs for qpmstpd I chose /usr/lib/perl5/site_perl, because that is in
@INC on all Redhat and Fedora versions since at least Redhat 7.3 (the
oldest version I am attempting to support).


>>> In particular where am I supposed to put modules used by scripts that
>>> only have to run in my system, and where am I supposed to put
>>> modules in a source perl package (/usr/local/share/perl,
>>> /usr/local/lib/perl, /usr/local/share/perl5, /usr/local/lib/perl5 ?).
>>
>> Use Module::Builder or ExtUtils::MakeMaker to install your modules. That
>> will "do the right thing" if perl was setup sanely by your linux
>> distribution (as is the case for Debian Etch).
>>
>
> Yes, it's a wise advice, but I was trying to build a package with a
> perl script and a specific perl module (not meant to be used
> indipendently from the script), and I wanted to avoid to mix autoconf
> and MakeMaker, so the simple solution seemed to detect the
> installation dirs without to rely on not autoconf/make tools.

I don't see what you need autoconf for, but then I don't know your
script.

        hp


--
_ | Peter J. Holzer | > it's the auto-tools that are somewhat
|_|_) | Schriftführer LUGA | > harder to grasp.
| | | hjp@luga.at | I think they try to avoid being grasped so
__/ | http://www.luga.at/ | people don't choke them to death. --mattdm

Similar ThreadsPosted
installing files in /usr/lib/share with MakeMaker October 9, 2005, 3:30 pm
Difference in digest and md5_hex December 9, 2004, 5:32 pm
compatibility of Perl5.84 and GD.1.18 on Windows October 13, 2004, 6:24 pm
prebuilt DBI/DBD Oracle for solaris 8, perl5.00503 February 27, 2005, 10:22 am
SOAP::Lite Solaris Perl5.005 'Can't locate warnings.pm' March 15, 2007, 11:59 am
ANNOUNCE: Initial release of WSF/Perl (Perl bindings for a WS-* framework) October 4, 2007, 1:37 am
PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please. July 13, 2004, 4:06 am
Perl MakeMaker - how to force Perl linking with the static C library (libcrt.lib) instead of dynamic C library (msvcrt.lib) April 17, 2007, 5:22 pm
MFC with Perl July 19, 2005, 9:38 pm
Net::SSH::Perl October 23, 2005, 11:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap